package com.aivin.tvslidebar.activity;

import android.os.Bundle;
import android.view.WindowManager;

import androidx.appcompat.app.ActionBar;
import androidx.appcompat.app.AppCompatActivity;

import com.aivin.tvslidebar.R;
import com.aivin.tvslidebar.customview.WheelView;

import java.util.ArrayList;
import java.util.List;


/**
 * @author ly-dengpw
 */
public class MainActivity extends AppCompatActivity {
    private static final int FLAT_REQUEST_CODE = -10086;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
                WindowManager.LayoutParams.FLAG_FULLSCREEN);

        setContentView(R.layout.activity_main);

        ActionBar actionBar = getSupportActionBar();
        if (actionBar != null) {
            actionBar.hide();
        }

        initView();
    }


    private void initView() {
        WheelView scroll_iso = findViewById(R.id.scroll_iso);
        ArrayList<String> isoVaules = getISOValueUI();
        scroll_iso.setItems(isoVaules);
        scroll_iso.selectIndex(2);
        scroll_iso.setMaxSelectableIndex(isoVaules.size() - 1);
        scroll_iso.setOnWheelItemSelectedListener(selectedListener);
    }

    /**
     * 滑轮滚动监听器
     */
    private WheelView.OnWheelItemSelectedListener selectedListener = new WheelView.OnWheelItemSelectedListener() {
        @Override
        public void onWheelItemChanged(WheelView wheelView, int position) {

        }

        @Override
        public void onWheelItemSelected(WheelView wheelView, int position, List<String> values) {
            String str = values.get(position);

        }
    };

    public ArrayList<String> getISOValueUI() {
        ArrayList<String> isoValues = new ArrayList<>();
        isoValues.add("100");
        isoValues.add("300");
        isoValues.add("600");
        isoValues.add("1300");
        isoValues.add("3200");
        isoValues.add("7000");
        isoValues.add("11000");
        isoValues.add("24000");
        isoValues.add("50000");
        isoValues.add("100000");
        isoValues.add("200000");
        isoValues.add("280000");
        return isoValues;
    }
    //@RequiresApi(api = Build.VERSION_CODES.M)
    //@Override
    //protected void onResume() {
    //    super.onResume();
    //    boolean hasOverlayPermission = Settings.canDrawOverlays(this);
    //
    //    if (!hasOverlayPermission) {
    //        Intent intent = new Intent(Settings.ACTION_MANAGE_OVERLAY_PERMISSION);
    //        startActivityForResult(intent, FLAT_REQUEST_CODE);
    //        return;
    //    }
    //    startWindow();
    //}
    //
    //private void startWindow(){
    //    SideBarGuidViewTool.getInstance().init(this);
    //}
}
